//
//  QianKuanViewController.m
//  JinChengYun
//
//  Created by 金橙云 on 2017/3/13.
//  Copyright © 2017年 金橙云. All rights reserved.
//

#import "QianKuanViewController.h"

#import "QianKuanCell.h"
#import "GouDetailsViewController.h"
@interface QianKuanViewController ()<UITableViewDelegate,UITableViewDataSource>
{
     NSMutableArray *_qianArr;
}
@property(nonatomic,strong)UITableView *tabView;
@end

@implementation QianKuanViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   self.title = @"首付待催款";
    
    _qianArr = [NSMutableArray arrayWithCapacity:0];
    _qianArr = [_qianDic objectForKey:@"data"];
    _tabView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, B_WIDTH, B_HEIGHT) style:UITableViewStylePlain];
    _tabView.delegate = self;
    _tabView.dataSource = self;
    _tabView.rowHeight = 90;
    _tabView.backgroundColor = BgColor;
    _tabView.separatorStyle = UITableViewCellSelectionStyleNone;//去掉cell的分割线
    [self.view addSubview:_tabView];

    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [_qianStr intValue];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellID = @"Cell";
    QianKuanCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (cell == nil)
    {
        cell = [[QianKuanCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }
    if ([cell isKindOfClass:[QianKuanCell class]])
    {
        if (_qianArr.count != 0)
        {
            NSDictionary *dict = [_qianArr objectAtIndex:indexPath.row];
            
            [(QianKuanCell *)cell setUpQianKuanCellWithName:dict[@"rengou_name"] withGouDate:dict[@"rengou_time"] withGenHouse:dict[@"fy_name"] withPay:dict[@"pay_way"]?dict[@"pay_way"]:@"" withYing:dict[@"should_pay_money"] withShi:dict[@"true_pay_money"] withQian:dict[@"owe_money"] withPhone:dict[@"rengou_phone"]];
            
        }
    }
    
      [cell setSelectionStyle:UITableViewCellSelectionStyleNone];//取消点击
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    GouDetailsViewController *gouDetailsVC = [[GouDetailsViewController alloc] init];
    gouDetailsVC.idStr = [[_qianArr objectAtIndex:indexPath.row] objectForKey:@"id"];
   
    [self.navigationController pushViewController:gouDetailsVC animated:NO];
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
